--尖刀为己所伤
local jiandaoweijisuoshang = fk.CreateSkill {
    name = "mcdh_jiandaoweijisuoshang",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

jiandaoweijisuoshang:addEffect(fk.CardUseFinished,{
    can_trigger = function(self, event, target, player, data)
        return data.from == player.id and player:hasSkill(self) and
                player:usedSkillTimes(self.name, Player.HistoryTurn) == 0 and data.tos and
                (data.card.trueName == "slash")
    end,
    on_cost = function(self, event, target, player, data)
        local cards = player.player_cards[Player.Hand]
        local suitcard = table.filter(cards, function(id) return Fk:getCardById(id).trueName == "jink" end)
        local ids, choice = U.askforChooseCardsAndChoice(player, suitcard, { "mcdh_JDWJSS_discard" }, self.name,
                "#mcdh_JDWJSS_view", { "mcdh_JDWJSS_hurtself", "Cancel" }, 1, 1, cards)
        if choice ~= "Cancel" then
            self.cost_data = { choice, ids }
            return true
        end
    end,
    on_use = function(self, event, target, player, data)
        if self.cost_data[1] == "mcdh_JDWJSS_discard" then
            player.room:throwCard(self.cost_data[2], self.name, player, player)
        else
            player.room:damage {
                from = player,
                to = player,
                damage = 1,
                damageType = fk.NormalDamage,
                skillName = self.name,
            }
        end
        local testdata = data
        testdata.additionalEffect = 0
        player.room:doCardUseEffect(testdata)
    end,
})

Fk:loadTranslationTable {
    ["mcdh_jiandaoweijisuoshang"] = "自诀",
    [":jiandaoweijisuoshang"] = "『尖刀为己所伤』<br>每回合限一次，当你使用的【杀】结算后，你可以弃置一张【闪】或受到1点伤害，令此牌额外结算一次。",
    ["#mcdh_JDWJSS_view"] = "尖刀为己所伤: 弃置一张【闪】或受到1点伤害，令此牌额外结算一次。",
    ["mcdh_JDWJSS_discard"] = "弃置一张【闪】",
    ["mcdh_JDWJSS_hurtself"] = "对自己造成1点伤害",
}
return jiandaoweijisuoshang